/**
 * 病例操作日志管理初始化
 */
var SdsQcincaseOperlog = {
    id: "SdsQcincaseOperlogTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

function paramsMatter(value,row,index) {
    var result='<p style="word-wrap: break-word;white-space: normal;word-break: break-all;">' + value + "</p>"
    return result;
}

/**
 * 初始化表格的列
 */
SdsQcincaseOperlog.initColumn = function () {
    return [
        {
            align: "center",
            valign: 'middle',
            align: 'center',
            width: 40,
            sortable: true,
            formatter: function (value, row, index) {
                //获取每页显示的数量
                var pageSize = $('#SdsQcincaseOperlogTable').bootstrapTable('getOptions').pageSize;
                //获取当前是第几页
                var pageNumber = $('#SdsQcincaseOperlogTable').bootstrapTable('getOptions').pageNumber;
                //返回序号，注意index是从0开始的，所以要加上1
                return pageSize * (pageNumber - 1) + index + 1;
            }
        },
        {
            title: '操作类型',
            field: 'operState',
            width: 100,
            align: 'center',
            valign: 'middle',
            sortable: true,
            formatter: function (value) {
                var result = '';
                switch (value) {
                    case 'I':
                        result = '入组';
                        break;
                    case 'O':
                        result = '排除';
                        break;
                    case 'Save':
                        result = '保存';
                        break;
                    case 'Submit':
                        result = '提交';
                        break;
                    case 'Up':
                        result = '上报';
                        break;
                    case 'Check':
                        result = '审核';
                        break;
                    case 'Back':
                        result = '退回';
                        break;
                    default:
                        break;
                }
                return result;
            }
        },
        {title: '操作人', field: 'operUser', width: 100, align: 'center', valign: 'middle', sortable: true},
        {title: '时间', field: 'operDate', width: 150, align: 'center', valign: 'middle', sortable: true},
        {title: '原因', field: 'operReasonDesc', width: 200, align: 'center', valign: 'middle', sortable: true,formatter:paramsMatter},
        {title: '备注', field: 'operResume', width: 200, align: 'center', valign: 'middle', sortable: true,formatter:paramsMatter}
    ];
}

$(function () {
    var defaultColunms = SdsQcincaseOperlog.initColumn();
    var table = new BSTable(SdsQcincaseOperlog.id, "/sds/sdsqcincaseoperlog/list", defaultColunms);
    table.setPaginationType("server");
    table.setShowRefresh(false);
    table.setShowToggle(false);
    table.setShowExport(false);
    table.setShowColumns(false);
    table.setQueryParams({"inCaseId": $("#mrListId").val()});
    var b_height = document.documentElement.clientHeight;
    table.setHeight(b_height - 20);
    SdsQcincaseOperlog.table = table.init();
});
